package com.sunmouse.toolkit.constant;

/**
 * Created by Administrator on 2017/8/23.
 */
public class Media {

    //radio
    public static final String[] RADIO = {
            "mp3"
    };

    //video
    public static final String[] VIDEO = {
            "rm",
            "rmvb",
            "wmv",
            "avi",
            "mp4",
            "3gp",
            "mkv"
    };

    //compress
    public static final String[] COMPRESS_FILE = new String[]{
            "rar",
            "zip"
    };

    //doc
    public static final String[] DOC = new String[]{
            "txt",
            "pdf",
            "doc",
            "docs"
    };

    /**
     * is radio
     */
    private static boolean isMedia(String fName, String[] media) {
        if (!fName.contains(".")) return false;
        String temp = fName.substring(fName.lastIndexOf(".") + 1, fName.length());
        for (String s : media) {
            if (s.equals(temp)) return true;
        }
        return false;
    }

    /**
     * is radio ?
     */
    public static boolean isRadio(String fName) {
        return isMedia(fName, RADIO);
    }

    /**
     * check whether fName is a video
     *
     * @param fName
     * @return
     */
    public static boolean isVideo(String fName) {
        return isMedia(fName, VIDEO);
    }

    /**
     * compressed file
     *
     * @param fName
     * @return
     */
    public static boolean isCompress(String fName) {
        return isMedia(fName, COMPRESS_FILE);
    }

    /**
     * document file
     *
     * @param fName
     * @return
     */
    public static boolean isDoc(String fName) {
        return isMedia(fName, DOC);
    }
}
